package com.oa.modules.approvalsec1.controller;

import java.util.Arrays;
import java.util.Date;
import java.util.Map;

import com.oa.common.utils.AppUtils;
import com.oa.modules.approvalsec1.entity.IntelligentOfficeEntity;
import com.oa.modules.approvalsec1.service.IntelligentOfficeService;
import com.oa.modules.sys.controller.AbstractController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.oa.common.utils.PageUtils;
import com.oa.common.utils.R;



/**
 * 智能办
 *
 * @author jiangwei
 * @email 785297226@qq.com
 * @date 2021-10-18 16:40:48
 */
@RestController
@RequestMapping("generator/intelligentoffice")
@Api(tags =   "智能办相关接口")
public class IntelligentOfficeController extends AbstractController {
    @Autowired
    private IntelligentOfficeService intelligentOfficeService;

    /**
     * 列表
     */
    @GetMapping("/list")
    @ApiOperation(value = "列表")
    @RequiresPermissions("generator:intelligentoffice:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = intelligentOfficeService.queryPage(params);
        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @GetMapping("/info/{id}")
    @RequiresPermissions("generator:intelligentoffice:info")
    @ApiOperation(value = "信息")
    public R info(@PathVariable("id") Integer id){
		IntelligentOfficeEntity intelligentOffice = intelligentOfficeService.getById(id);
        return R.ok().put("intelligentOffice", intelligentOffice);
    }

    /**
     * 保存
     */
    @PostMapping("/save")
    @ApiOperation(value = "保存")
    @RequiresPermissions("generator:intelligentoffice:save")
    public R save(@RequestBody IntelligentOfficeEntity intelligentOffice){
        intelligentOffice.setId(AppUtils.getUUID());
        intelligentOffice.setCreateDate(new Date());
        intelligentOffice.setCreateOper(getUserId().toString());
		intelligentOfficeService.save(intelligentOffice);
        return R.ok();
    }

    /**
     * 修改
     */
    @PostMapping("/update")
    @ApiOperation(value = "修改")
    @RequiresPermissions("generator:intelligentoffice:update")
    public R update(@RequestBody IntelligentOfficeEntity intelligentOffice){
        intelligentOffice.setUpdateDate(new Date());
        intelligentOffice.setUpdateOper(getUserId().toString());
		intelligentOfficeService.updateById(intelligentOffice);
        return R.ok();
    }

    /**
     * 删除
     */
    @PostMapping("/delete")
    @ApiOperation(value = "删除")
    @RequiresPermissions("generator:intelligentoffice:delete")
    public R delete(@RequestBody Integer[] ids){
		intelligentOfficeService.removeByIds(Arrays.asList(ids));
        return R.ok();
    }

}
